package com.pioneer.admin.controller.cron;

import com.pioneer.web.book.service.IBorrowRecordService;
import jakarta.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author aom-star@outlook.com
 * @date 2025/5/22
 * @description 定时任务
 */
@Component
public class CronCheckTask {
    @Resource
    IBorrowRecordService borrowRecordService;


    @Scheduled(cron = "0 0 3 1 * ?") // 每月1号凌晨3点执行
    public void cleanOldBorrowRecords() {
        borrowRecordService.cleanOldRecords();
    }

    @Scheduled(cron = "0 0 3 * * ?") // 每天凌晨3点执行一次
    public void checkOverdueBooks() {
        borrowRecordService.updateOverdueStatus();
    }
}
